package top.go2do.auth.business.role.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import top.go2do.auth.business.role.module.RolePermissionPO;

import java.util.List;
import java.util.Set;

/**
 * @Description
 * @Author xingyj
 * @CreateTime 2025/3/17 10:21
 */
public interface RolePermissionRepository extends JpaRepository<RolePermissionPO, Long>, JpaSpecificationExecutor<RolePermissionPO> {
    List<RolePermissionPO> findByRoleIdIn(Set<Long> roleIdSet);


    @Transactional
    @Modifying
    @Query("DELETE FROM RolePermissionPO rp WHERE rp.roleId = ?1") // 根据email删除
    int deleteByRoleId(Long roleId);
}
